/*****************************************************************************
 *
 * Copyright (c), 2004-2020,ShangHai Neotune Information Technology Co., Ltd.
 *
 * Module Name : glue.h
 *
 * Author :    sean
 *
 * Date :    2004-02-05
 *
 * Version :    1.00
 *
 * Description :    
 *
 * Other :    
 *
 * Data Structure List: <Main Data Structure>
 *
 * Modification History
 * ---------------------------------------------------------------------------
 *  1: Data :      2004-02-05
 *    Author :     sean
 *    Version :    V100R001M00
 *    Modification : creation
 *
*****************************************************************************/

#ifndef COMMON_GLUE_H
#define COMMON_GLUE_H

/*
 * Load the postamble portion of the customer's common.h file.
 */

#include "common.h"
#include "stdf.h"

#if INSTALL_COMMON_SNPRINTF
#include <snprintf.h>
#endif

/*
 * Default definitions for macros that stand in for ANSI functions.
 * These may need to be fine-tuned after we've run some compilation tests.
 */

#ifndef MEMCHR
#define MEMCHR(x,y,z)           memchr(x,y,z)
#endif

#ifndef MEMCMP
#if INSTALL_COMMON_MEMCMP
#define MEMCMP(x,y,z)           etc_memcmp(x,y,z)
#else
#define MEMCMP(x,y,z)           memcmp(x,y,z)
#endif
#endif

#ifndef MEMCPY
#define MEMCPY(x,y,z)           memcpy(x,y,z)
#endif

#ifndef MEMSET
#define MEMSET(x,y,z)           memset(x,y,z)
#endif

#ifndef STRCMP
#define STRCMP(x,y)             strcmp(x,y)
#endif

#ifndef STRCPY
#define STRCPY(x,y)             strcpy(x,y)
#endif

#ifndef STRLEN
#define STRLEN(x)               strlen(x)
#endif

#ifndef STRNCMP
#define STRNCMP(x,y,z)          strncmp(x,y,z)
#endif

#ifndef STRTOL
#if (INSTALL_COMMON_STRTOL)
#define STRTOL(S, E, R)         etc_strtol(S, E, R)
#else
#define STRTOL(S, E, R)         strtol(S, E, R)
#endif
#endif

#ifndef STRTOUL
#if (INSTALL_COMMON_STRTOUL)
#define STRTOUL(S, E, R)        etc_strtoul(S, E, R)
#else
#define STRTOUL(S, E, R)        strtoul(S, E, R)
#endif
#endif

/*
 * These two aren't ANSI functions, but their ANSI equivilents have a
 * serious design flaw: there's no way to specify the length of the
 * output buffer, so careless use of the ANSI function can ruin your
 * whole day.  Get a clue, ANSI.
 *
 * We provide implementations of these in the common library.
 */

#ifndef SNPRINTF
#if INSTALL_COMMON_SNPRINTF
#define SNPRINTF                etc_snprintf
#else
#define SNPRINTF                snprintf
#endif
#endif

#ifndef VSNPRINTF
#if INSTALL_COMMON_SNPRINTF
#define VSNPRINTF               etc_vsnprintf
#else
#define VSNPRINTF               vsnprintf
#endif
#endif

/*
 * These two aren't ANSI functions, but most systems have equivilents.
 * They're case-insensitive versions of the corresponding ANSI functions.
 * We provide implementations of these in the common library.  */

#ifndef STRICMP
#if (INSTALL_COMMON_STRICMP)
#define STRICMP(x, y)           etc_stricmp(x, y)
#else
#define STRICMP(x, y)           strcasecmp(x, y)
#endif
#endif

#ifndef STRNICMP
#if (INSTALL_COMMON_STRNICMP)
#define STRNICMP(x, y, z)       etc_strnicmp(x, y, z)
#else
#define STRNICMP(x, y, z)       strncasecmp(x, y, z)
#endif
#endif

#endif /* COMMON_GLUE_H */

